const mongoose = require('mongoose');

const DB_URL = 'mongodb://localhost:27017/local';

mongoose.connect(DB_URL);

//连接成功
mongoose.connection().on('connected',function(){
    console.log('[Mongoose] connect to '+DB_URL+' successfully');
});

//连接失败
mongoose.connection().on('error',function(err){
    console.log("[Mongoose] connection fail;");
    console.error(err);
});

//连接异常断开
mongoose.connection().on('disconnected',function(){
    console.log("[Mongoose] connection close unexpectedly");
});

module.exports = mongoose;